package com.talkweb.yingu.apimodel.admin;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by qsf on 2019/4/3.
 */
@Setter
@Getter
public class SysOrgVo implements Serializable {
    private static final long servialVersionUID=1L;
    @ApiModelProperty(value = "ID")
    private Long id;
    @ApiModelProperty(value="ORG_CODE")
    private String orgCode;
    @ApiModelProperty(value="ORG_NAME")
    private String orgName;
    @ApiModelProperty(value="ORG_TYPE")
    private String orgType;
    @ApiModelProperty(value="PARENT_ID")
    private String parentId;
    @ApiModelProperty(value="PARENT_IDS")
    private String parendIds;
    @ApiModelProperty(value="ORDER_BY")
    private String orderBy;
    @ApiModelProperty(value="VALIDATE_STATE")
    private String validateState;
    @ApiModelProperty(value="IS_VIRTUAL")
    private String isVirtual;
    @ApiModelProperty(value="VERSION")
    private Long version;   //???
    @ApiModelProperty(value="APP_FLAG")
    private String appFlag;
    @ApiModelProperty(value="IS_LEEF")
    private String isLeef;
    @ApiModelProperty(value="AREA_CODES")
    private String areaCodes;
    @ApiModelProperty(value="AREA_ADRESS")
    private String areaAdress;
    @ApiModelProperty(value="ORG_LEVEL")
    private String orgLevel;
    @ApiModelProperty(value="EFFECTIVE_DATE")
    private Date effectiveDate;

    @ApiModelProperty(value="CREATE_TIME")
    private Date createTime;
    @ApiModelProperty(value="UUID")
    private String uuid;
    @ApiModelProperty(value="remark")
    private String remark;

    public static List<TreeNodeVo> toTreeModel(List<SysOrgVo> list) {
        List<TreeNodeVo> nodeList = new ArrayList<>();
        for(SysOrgVo sysOrgVo: list) {
            TreeNodeVo node = new TreeNodeVo();
            node.setId(sysOrgVo.getId().toString());
            node.setName(sysOrgVo.getOrgName());
            node.setParentId(sysOrgVo.getParentId());
            node.setLevel(sysOrgVo.getOrgLevel());
            node.setOrgType(sysOrgVo.getOrgType());
            node.setValidateState(sysOrgVo.getValidateState());
            nodeList.add(node);
        }
        return TreeNodeVo.treeBuild(nodeList);
    }
}
